package com.diy.sigmund.diycommon.designpatterns.strategy.duck;

import com.diy.sigmund.diycommon.designpatterns.strategy.duck.flybehavior.FlyRocketPowered;
import com.diy.sigmund.diycommon.designpatterns.strategy.duck.flybehavior.FlyWithWings;
import com.diy.sigmund.diycommon.designpatterns.strategy.duck.quackbehavior.Quack;

/**
 * 绿头鸭子
 *
 * @author ylm-sigmund
 * @since 2022/1/13 10:20
 */
public class GreenHeadDuck extends Duck {

    public GreenHeadDuck() {
        flyBehavior = new FlyWithWings();
        quackBehavior = new Quack();
    }

    @Override
    public void display() {
        System.out.println("GreenHeadDuck");
    }
    public static void main(String[] args) {
        Duck greenHeadDuck = new GreenHeadDuck();
        greenHeadDuck.display();
        greenHeadDuck.performQuack();
        greenHeadDuck.swim();
        greenHeadDuck.performFly();

        System.out.println("========================");

        // 橡皮鸭子
        Duck rubberDuck = new RubberDuck();
        rubberDuck.display();
        rubberDuck.performQuack();
        rubberDuck.swim();
        rubberDuck.performFly();

        System.out.println("========================");
        Duck modelDuck = new ModelDuck();
        modelDuck.display();
        modelDuck.performFly();
        modelDuck.setFlyBehavior(new FlyRocketPowered());
        modelDuck.performFly();
        modelDuck.a();
    }
}
